<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cn.vuejs.org/js/vue.js"></script>
    <link rel="stylesheet" href="/static/css/alreadySell.css">
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <link rel="stylesheet" href="../static/layui/css/layui.css">
    <script src="../static/layui/layui.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div id="alreadySell">
    <span th:text="${session.user.getUser_id()}" hidden="hidden" id="user_id_span"></span>
    <div class="goodsListBox" v-for="item in List">
        <div class="left_div">
            <img id="goods_picture" :src="item.goods_picture" alt="">
        </div>
        <div class="right_div">
            <div class="goods_describe">
                <span>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;{{item.goods_describe}}</span>
            </div>
            <div class="price_btn">
                <div class="goods_price">
                    <div style="margin-top: 11px">
                        <span style="font-size: 25px;color: red">￥{{item.goods_price}}</span>
                    </div>
                </div>
                <div class="btn_box">
                    <button class="layui-btn layui-btn-fluid layui-btn-danger" @click="deleteMyGoods(item.goods_id)">删除</button>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
<script>
    var user_id=document.getElementById("user_id_span").innerText;
    var app=new Vue({
        el:"#alreadySell",
        data:{
            List:""
        },
        methods:{
            deleteMyGoods:function (goods_id) {
                axios.get("/deleteMyGoods?user_id="+user_id+"&goods_id="+goods_id).then(function (response) {
                    console.log(response.data);
                    if (response.data === true){
                        layer.msg("操作成功!", {icon:1,time:1000},function(){
                            setTimeout('window.location.reload()',10);
                        });
                    }
                },function (err) {
                    console.log(err);
                });
            },
        }
    });

    axios.get("/alreadySellGoods?user_id="+user_id).then(function (response) {
        app.List=response.data;
    },function (err) {
        console.log(err);
    });
</script>
</html>